<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <ul>
            <li v-for="student in students" :key="student.id" :title="student.name" @click="show">
                {{student.id}}.{{ student.name }}-{{ student.age }}-{{ student.gender }}
            </li>
        </ul>
    </div>
    <script src=" ../assets/vue3.js">
    </script>
    <script>
        const app = Vue.createApp({
            data() {
                return {
                    students: [
                        { id: 1, name: '张三', age: 22, gender: '男' },
                        { id: 2, name: '李四', age: 29, gender: '女' },
                        { id: 3, name: '王二', age: 32, gender: '男' }
                    ]
                }
            },
            methods: {
                show(event) {
                    //如果@click后面方法没有参数，默认就是传event回来
                    // 通过 event.target 获取的是 <li> 元素本身，而不是student对象
                    console.log(event.target.title);
                }
            },
        });
        app.mount('#app');
    </script>
</body>

</html>